package fudan.se.lab2.controller;

import fudan.se.lab2.domain.Contribution;
import fudan.se.lab2.domain.Mark;
import fudan.se.lab2.domain.Meeting;
import fudan.se.lab2.service.UserUtilService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserUtilController {
    private final UserUtilService userUtilService;

    @Autowired
    public UserUtilController(UserUtilService userUtilService) {
        this.userUtilService = userUtilService;
    }

    @PostMapping("/meetingIApplied")
    public ResponseEntity<List<Meeting>> meetingIApplied(@RequestBody String userName) {
        return ResponseEntity.ok(userUtilService.meetingIApplied(userName));
    }

//    @PostMapping("/test")
//    public ResponseEntity<?> test() {
//        System.out.println("hahahahaha");
//        return ResponseEntity.ok(true);
//    }
//    @PostMapping("/test1")
//    public ResponseEntity<?> test1() {
//        System.out.println("bbbbbbb");
//        return ResponseEntity.ok("wuyanjie");
//    }


    @PostMapping("/meetingIEnded")
    public ResponseEntity<List<Meeting>> meetingIEnded(@RequestBody String userName) {
        return ResponseEntity.ok(userUtilService.meetingIEnded(userName));
    }

    @PostMapping("/meetingIJoined")
    public ResponseEntity<List<Meeting>> meetingIJoined(@RequestBody String userName) {
        return ResponseEntity.ok(userUtilService.meetingIJoined(userName));
    }

    @PostMapping("/meetingIContributed")
    public ResponseEntity<List<Contribution>> meetingIContributed(@RequestBody String userName) {
        return ResponseEntity.ok(userUtilService.meetingIContributed(userName));
    }

    @PostMapping("/meetingInvitedMe")
    public ResponseEntity<List<Meeting>> meetingInvitedMe(@RequestBody String userName) {
        return ResponseEntity.ok(userUtilService.meetingInvitedMe(userName));
    }

    @PostMapping("/myResults")
    public ResponseEntity<List<Mark>> marksIGotInThisMeeting(@RequestBody String userName) {
        return ResponseEntity.ok(userUtilService.marksIGotInThisMeeting(userName));
    }
}
